-
Notifications
You must be signed in to change notification settings - Fork 245
REPORT-912: Update to OpenMRS platform 2.7.3 and Support Java 21 #261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Can we add include the other Java versions in the build? |
| //import org.openmrs.util.OpenmrsUtil; | ||
| // | ||
| ///** | ||
| // * The logic that evaluates a {@link DataExportDataSetDefinition} and produces a {@link DataSet} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a deprecated class. So I am deleting this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you see the above comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. Sorry, my mistake. I am working on this.
| return x != null && x.equals(y); | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these formatting changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I replaced this with PropertiesType in api-2.4. We have to remove this when removing the sub-module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before removing the submodule, can we avoid touching this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dkayiwa We need to update the nullSafeGet and nullSafeSet methods; without doing so, the code won't compile. I reverted the file temporarily, and as you can see from the build, it's failing with compile errors:
https://github.com/openmrs/openmrs-module-reporting/actions/runs/15436424952/job/43443786399
| assertThat(persistedDefinition, notNullValue()); | ||
| assertThat(persistedDefinition.getName(), is("Patients in 2006 by indicators")); | ||
| assertThat(persistedDefinition.getSpecifications(), not(empty())); | ||
| // executeDataSet("org/openmrs/module/reporting/include/DefinitionServiceTest.xml"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a deprecated class. So I am deleting this.
| //import org.openmrs.reporting.export.DataExportReportObject; | ||
| //import org.openmrs.test.BaseModuleContextSensitiveTest; | ||
| //import org.openmrs.test.StartModule; | ||
| // |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a deprecated class. So I am deleting this.
| /** | ||
| * @see UserType#equals(Object, Object) | ||
| */ | ||
| public boolean equals(Object x, Object y) throws HibernateException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting changes again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just replaced this with ReportDefinitionType in api-2.4. We have to remove this when removing the sub-module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just do not seem to understand what is going on here. I see it deleted and added back in the same file.
| import org.hibernate.usertype.CompositeUserType; | ||
| import org.hibernate.usertype.UserType; | ||
| import org.openmrs.module.reporting.common.HibernateUtil; | ||
| import org.openmrs.module.reporting.report.renderer.RenderingMode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just replaced this with RenderingModeType in api-2.4. We have to remove this when removing the sub module.
Line 38 in 5419198
| public class RenderingModeType implements CompositeUserType { |
api-1.9/pom.xml
Outdated
| <dependency> | ||
| <groupId>org.openmrs.module</groupId> | ||
| <artifactId>reportingcompatibility-api</artifactId> | ||
| <version>3.0.0-SNAPSHOT</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you forget to add scope here?
| /** | ||
| * @see UserType#assemble(Serializable, Object) | ||
| */ | ||
| public Object assemble(Serializable cached, Object owner) throws HibernateException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there where you added it after deleting it from the above?
| public class RenderingModeType implements CompositeUserType { | ||
|
|
||
| /** | ||
| * @see CompositeUserType#returnedClass() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this deleting and then adding it back as new?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dkayiwa, what's happening here is that method signatures like nullSafeGet have changed in newer platform versions. Specifically:
CompositeUserType#nullSafeGet(ResultSet, String[], SharedSessionContractImplementor, Object)
has been updated to:
CompositeUserType#nullSafeGet(ResultSet, String[], SharedSessionContractImplementor, Object)
Previously, I took a shortcut by copying these classes from the 2.4 branch, since we're planning to remove these classes when we eventually merge the legacy submodules. I've now updated the PR to avoid confusion.
| public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException { | ||
| String parameterizableUuid = (String) HibernateUtil.standardType("STRING").nullSafeGet(rs, names[0], session, owner); | ||
| if (StringUtils.isEmpty(parameterizableUuid)) { return null; } | ||
| String serializedMappings = (String) HibernateUtil.standardType("STRING").nullSafeGet(rs, names[1], session, owner); | ||
| Definition d = DefinitionContext.getDefinitionByUuid(mappedType, parameterizableUuid); | ||
| Map<String, Object> mappings = new HashMap<String, Object>(); | ||
| if (StringUtils.isNotBlank(serializedMappings)) { | ||
| try { | ||
| mappings = Context.getSerializationService().deserialize(serializedMappings, Map.class, ReportingSerializer.class); | ||
| } | ||
| catch (Exception e) { | ||
| throw new HibernateException("Unable to deserialize parameter mappings for definition", e); | ||
| } | ||
| } | ||
| return new Mapped(d, mappings); | ||
| } | ||
|
|
||
| /** | ||
| * @see CompositeUserType#nullSafeSet(PreparedStatement, Object, int, SharedSessionContractImplementor) | ||
| */ | ||
| public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { | ||
| String definitionUuid = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why GitHub is showing this as a completely new file. The only thing I did was change these methods :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When comparing these changes locally, I am not seeing this issue.
api/pom.xml
Outdated
| <groupId>org.openmrs.module</groupId> | ||
| <artifactId>reportingcompatibility-api</artifactId> | ||
| <version>${reportingCompatibilityVersion}</version> | ||
| <scope>provided</scope> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you change this scope?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am getting an error with the 'provided' scope.
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:98)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:124)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:118)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:248)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataExportDataSetDefinitionPersister': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.openmrs.module.reporting.dataset.definition.persister.DataExportDataSetDefinitionPersister] from ClassLoader [sun.misc.Launcher$AppClassLoader@75b84c92]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:298)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1302)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1219)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:921)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:127)
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60)
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:276)
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:244)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:141)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:90)
... 12 more
Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.openmrs.module.reporting.dataset.definition.persister.DataExportDataSetDefinitionPersister] from ClassLoader [sun.misc.Launcher$AppClassLoader@75b84c92]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:485)
at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:321)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:276)
... 29 more
Caused by: java.lang.NoClassDefFoundError: org/openmrs/reporting/AbstractReportObject
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2729)
at java.lang.Class.getDeclaredMethods(Class.java:2003)
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:467)
... 31 more
Caused by: java.lang.ClassNotFoundException: org.openmrs.reporting.AbstractReportObject
at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 35 more
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't have this scope changed from provided to compile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't have this scope changed from provided to compile.
@mseaton, do you know why this error is occurring?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes @wikumChamith . Currently, this class is in the api-1.9 maven submodule, which builds against OpenMRS 1.9 and is only conditionally loaded by OpenMRS if the core version is 1.9-1.12:
<conditionalResource>
<path>/lib/reporting-api-1.9.*</path>
<openmrsVersion>1.9.9 - 1.12.*</openmrsVersion>
</conditionalResource>
Now that you are trying to move this class into the main api maven submodule and have it build against OpenMRS 2.x, it is failing because the classes that it depends upon are no longer in core, but only found in the reportingcompatibility module.
Best thing to do is to try to get the DataExportDataSetEvaluator and DataExportDataSetDefinitionPersister to be conditionally loaded only if the reportingcompatibility module is running, and to make reportingcompatibility an aware-of dependency in config.xml, and a provided dependency in the pom, but I'm not sure that's possible to do with the Handler annotation.
We might also just remove support for these constructs from the reporting module, since I'm not confident that anyone actually ever used them, and it is even more likely that no one is currently using them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am in favour of removing them to make things simpler. If any one ever complains about them, we can then look into bringing them back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing those two classes fixed the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great - can you remove the reportingcompatibility dependency entirely then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed it.
7d3a450 to
88d0b8b
Compare
|
@wikumChamith would it require as many changes if we simply changed the platform version to 2.4.0? You can clearly see that iam trying to do a step by step upgrade in order to limit the number of changes, especially for these complicated modules. 😊 |
|
e68ddeb to
1179b0f
Compare
|
@dkayiwa This is now ready to review. |
mseaton
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments. We cannot change module dependencies from provided to compile scope.
Ruhanga
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this is looking good — thanks @wikumChamith! I have a few suggestions that I believe would be a good fit to include in this PR.
...mrs/module/reporting/cohort/definition/evaluator/EncounterCohortDefinitionEvaluatorTest.java
Show resolved
Hide resolved
...penmrs/module/reporting/query/encounter/evaluator/MappedParametersObsQueryEvaluatorTest.java
Show resolved
Hide resolved
...t/java/org/openmrs/module/reporting/query/visit/evaluator/ActiveVisitQueryEvaluatorTest.java
Show resolved
Hide resolved
...s/src/test/java/org/openmrs/module/reporting/data/converter/PrivilegedDataConverterTest.java
Outdated
Show resolved
Hide resolved
...rc/test/java/org/openmrs/module/reporting/data/visit/evaluator/VisitIdDataEvaluatorTest.java
Outdated
Show resolved
Hide resolved
|
@Ruhanga, I’ve migrated the tests I touched in this PR to use Jupiter BaseModuleContextSensitiveTest. But if we’re planning to migrate all the tests in the module, I think it’s better to create a separate ticket. |
|
Correct and thanks @wikumChamith for the nice work. |
Ruhanga
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ruhanga
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mseaton
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks!
| */ | ||
| @TestExecutionListeners(OpenmrsVersionTestListener.class) | ||
| @RequiresVersion("2.4.* - 2.*") | ||
| public class EvaluationProfilerTest24On extends BaseModuleContextSensitiveTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did we remove this class?
| PowerMockito.when(Context.hasPrivilege(DOES_NOT_HAVE_PRIV)).thenReturn(false); | ||
| initializeInMemoryDatabase(); | ||
| executeDataSet("org/openmrs/module/reporting/include/PrivilegeTest.xml"); | ||
| Context.logout(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to log out and authenticate?
|
@dkayiwa I updated the PR. |
Ticket: https://openmrs.atlassian.net/browse/REPORT-912
legacy-branch: https://github.com/openmrs/openmrs-module-reporting/tree/1.x